package edu.gettysburg.catapp1;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class TourRecap extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tourrecap);

		String[] sites = new String[TourOverview.TOUR_OBJECT.getSites().size()];
		for(int i = 0; i < TourOverview.TOUR_OBJECT.getSites().size(); i++) {
			sites[i] = TourOverview.TOUR_OBJECT.getSites().get(i);
		}

		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.menulist, sites);

		ListView listView = (ListView) findViewById(R.id.tourlistView);
		listView.setAdapter(adapter);
		OnItemClickListener oicl = new OnItemClickListener(){

			public void onItemClick(AdapterView<?> parent, View view, int position,	long id) {
				Intent newActivity = new Intent();
				switch (position){
				default:
					InitialSite.SITE_NUM = position+1;
					newActivity = new Intent(getBaseContext(), InitialSite.class);     

					startActivity(newActivity);
					break;
				}
			}
		};
		listView.setOnItemClickListener(oicl);

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Intent intent = null;
		switch (item.getItemId()) {
		case R.id.menu_home:
			InitialSite.SITE_NUM = 1;
			intent = new Intent(getBaseContext(), mainmenu.class);
			startActivity(intent);
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.tourrecap, menu);
		return true;
	}


}
